package com.zhangyu.eat.me;

import android.support.v4.app.Fragment;
import android.util.SparseArray;

/**
 * Created by SoSho on 2016/10/7.
 */

public class FragmentFactory {
    private static final SparseArray<Fragment> fragments = new SparseArray<>();
    private static final int ONE_FRAGMENT = 0;
    private static final int TWO_FRAGMENT = 1;
    private static final int THREE_FRAGMENT = 2;
    private static final int FOUR_FRAGMENT = 3;
    private static final int FIVE_FRAGMENT = 4;



    public static Fragment creatFragment(int key) {
        Fragment fragment = fragments.get(key);
        if (fragment == null) {
            switch (key) {
                case ONE_FRAGMENT:
                    fragment= new GcFragment();
                    break;
                case TWO_FRAGMENT:
                    fragment= new GzFragment();
                    break;
                case THREE_FRAGMENT:
                    fragment= new BingFragment();
                    break;
                case FOUR_FRAGMENT:
                    fragment= new SxFragment();
                    break;
                case FIVE_FRAGMENT:
                    fragment= new MeFragment();
                    break;
            }
            fragments.put(key,fragment);
        }

    return fragment;
    }
}
